using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace FiltronASP.Models.Validators
{
    /// <summary>
    /// Walidator sprawdzajacy czy wprowadzona wartosc pasuje do adresu mailowego.
    /// </summary>
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
    public class EmailAttribute : RegularExpressionAttribute
    {
        private const string _pattern = @"^[\w\d!#$%&'*+-\/=?^`{|}~]+(\.[\w\d!#$%&'*+-\/=?^`{|}~]+)*@([a-z\d][-a-z\d]*[a-z\d]\.)+[a-z][-a-z\d]*[a-z]$";
        
        /// <summary>
        /// Konstruktor.
        /// </summary>  
        public EmailAttribute()
            : base(_pattern)
        {
        }

    }
}
